package org.azj.dbOperatorComponent;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class InsertCommand extends DbNonQueryCommand {
	String contents;
	String tableName;
	
	public InsertCommand(
			String tableName, 
			String contents)
	{
		this.tableName = tableName;
		this.contents = contents;
	}

	@Override
	public PreparedStatement getStatement(Connection conn) throws Exception
	{
		PreparedStatement preparedStatement = conn.prepareStatement(
				String.format("INSERT INTO %s VALUES (%s)", 
						tableName, contents));
		
		return preparedStatement;
	}
	
	@Override
	void doExecute(PreparedStatement preparedStatement) throws SQLException{
		preparedStatement.execute();
	}
}
